<template>
  <view style="padding: 30rpx 24rpx">
    <view style="display: flex; background: #ffffff; border-radius: 16rpx; padding: 28rpx 25rpx">
      <image
        src="https://static.tospurfang.com/saas/saas-pc/def_icon.png"
        mode="scaleToFill"
        style="width: 70rpx; height: 70rpx; border-radius: 35rpx" />
      <view style="line-height: 70rpx; margin-left: 15rpx; font-size: 28rpx; color: #333333">
        {{ userStore().info.userName }}{{ userStore().info.workNo }}
      </view>
    </view>
    <view style="border-radius: 16rpx; background: #ffffff; padding: 0 28rpx; margin-top: 30rpx">
      <view @click="onCustomer" class="func">
        <view class="title">我的客户</view>
        <view style="flex: 1"></view>
        <image
          style="width: 28rpx; height: 28rpx; margin-top: 35rpx"
          src="https://static.tospurfang.com/bd/right.png"
          mode="widthFix" />
      </view>
      <view @click="onAssetMine" class="func">
        <view class="title">我的上传资产</view>
        <view style="flex: 1"></view>
        <view v-if="messageStore().number" class="tip">{{ messageStore().number }}</view>
        <image
          style="width: 28rpx; height: 28rpx; margin-top: 35rpx"
          src="https://static.tospurfang.com/bd/right.png"
          mode="widthFix" />
      </view>
      <view @click="onAssetFocus" class="func">
        <view class="title">关注资产</view>
        <view style="flex: 1"></view>
        <image
          style="width: 28rpx; height: 28rpx; margin-top: 35rpx"
          src="https://static.tospurfang.com/bd/right.png"
          mode="widthFix" />
      </view>
    </view>
    <view
      @click="onLogout"
      style="
        width: 702rpx;
        height: 100rpx;
        background: #042275;
        border-radius: 16rpx;
        font-size: 32rpx;
        color: #ffffff;
        line-height: 100rpx;
        text-align: center;
        margin-top: 30rpx;
      ">
      退出登录
    </view>
  </view>
</template>

<script setup>
  import { messageStore } from '@/biz/message'
  import { onShow } from '@dcloudio/uni-app'

  import { userStore } from '@/biz/user'
  onShow(() => {
    messageStore().show(true)
  })

  function onLogout() {
    uni.showModal({
      title: '是否退出登录？',
      success: (res) => {
        if (res.confirm) {
          userStore().logout()
          uni.reLaunch({ url: '/pages/index/index' })
        }
      }
    })
  }

  function onCustomer() {
    uni.navigateTo({ url: '/pages/customer/list' })
  }
  function onAssetMine() {
    uni.navigateTo({ url: '/pages/asset/list' })
  }
  function onAssetFocus() {
    uni.navigateTo({ url: '/pages/asset/focus' })
  }
</script>
<style lang="scss" scoped>
  .func {
    display: flex;
    line-height: 88rpx;
    height: 88rpx;
    border-bottom: 1rpx #f5f5f5 solid;

    .title {
      font-size: 28rpx;
      color: #222222;
    }

    .tip {
      height: 30rpx;
      line-height: 28rpx;
      background: #f33c3c;
      font-size: 24rpx;
      color: #ffffff;
      padding: 0 10rpx;
      margin-top: 30rpx;
      border-radius: 15rpx;
    }
  }
</style>
